<?php

namespace App\service;

use app\common\MsgType;
use App\model\ChatHistory;
use GatewayWorker\Lib\Gateway;

class CommonService
{
    public static function chatLists($limit)
    {
        $ChatHistory = ChatHistory::query()->where('type', 1)->orderByDesc('id')->limit($limit)->get();
        $ChatHistory = $ChatHistory ? $ChatHistory->toArray() : [];
        return array_reverse($ChatHistory);
    }

    public static function sendPaomadeng($msg)
    {
        Gateway::sendToAll(json_encode([
            'type' => MsgType::S_3001,
            'content' => $msg,
        ]));
    }


}